import { StyleSheet, View } from 'react-native';
import React from 'react';
import MyVideoPlayer from '../../../components/MyVideoPlayer';
import MyTabs from '../../../components/MyTabs';
import OverviewSreen from '../OverviewSreen/OverviewSreen';
import DirectorySreen from '../DirectorySreen/DirectorySreen';
import EvaluateSreen from '../EvaluateSreen/EvaluateSreen';
import { useVideoPlayerStore } from '../../../store/VideoPlayer';

const CourseVideoPlaySreen = () => {
  const tabs = ['简介', '目录', '评价'];
  const [activeTab, setActiveTab] = React.useState(0);
  const activeTabHandler = (index: number) => {
    setActiveTab(index);
  };

  const { VideoPlayerSRc } = useVideoPlayerStore();

  return (
    <View style={styles.container}>
      <View style={styles.videoPlayer}>
        <MyVideoPlayer data={VideoPlayerSRc}/>
      </View>
      {/* tabs切换 */}
      <MyTabs tabs={tabs} activeTab={activeTab} onPress={activeTabHandler} />
      {/* 渲染的内容 */}
      <View style={{ padding: 10 }}>
        {activeTab === 0 && <OverviewSreen />}
        {activeTab === 1 && <DirectorySreen />}
        {activeTab === 2 && <EvaluateSreen />}
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
  },
  videoPlayer: {
    width: '100%',
    height: 200,
  },
});

export default CourseVideoPlaySreen;
